    define(function() {
        function Tool() {
            var self = this;
            /***
             *设置deep link
             */
            this.deepLink = function(name) {
                if (name == window.location.hash.replace("#!\/|#\/", "")) return;
                window.location.replace("#!/" + name); //深度转到这个页面
            };

            this.dateset = function(ta, name) {
                return (ta.dataset && ta.dataset.name) || ta.getAttribute("data-" + name);
            };

            /***
             ** 操作系统
             **/
            this.type = function(t) {
                switch (t) {
                    case 1:
                        return "ios";
                    case 2:
                        return "Android";
                    case 3:
                        return "ipad";
                    default:
                        return "unknow";
                }
            }
            this.toThousands = function(num) {
                var result = [],
                    counter = 0;
                num = (num || 0).toString().split('');
                for (var i = num.length - 1; i >= 0; i--) {
                    counter++;
                    result.unshift(num[i]);
                    if (!(counter % 3) && i != 0) { result.unshift(','); }
                }
                return result.join('');
            }

            /**
             **
             **/
            this.format = function(arr, idP, textP, defaultName, fun) {
                var idP = idP || "id"
                var textP = textP || "name";
                var newArr = [];
                if (arr && arr.length) {
                    if (fun && typeof(fun) == "function") arr.unshift(fun());
                    for (var i = 0; i < arr.length; i++) {
                        var the = arr[i];
                        the.id = the[idP] || i;
                        the.text = the[textP]
                    }
                    if (defaultName && defaultName.length > 0) {
                        var o = { id: "-1" };
                        o.text = defaultName;
                        newArr = [o].concat(arr);
                    } else {
                        newArr = [].concat(arr);
                    }
                }
                return newArr;
            }

            this.region = function(arr, key) {
                for (var m = 0; m < arr.length; m++) {
                    if (arr[m].key == key) return arr[m].region;
                }
                return [];
            }

            this.ids = function(arr, p) {
                p = p || "id";
                var o = [];
                if (arr) {
                    for (var i = 0; i < arr.length; i++) {
                        var the = arr[i];
                        if (!the) continue;
                        if (the[p]) {
                            o.push(the[p]);
                        }
                    }
                }
                return o;
            }

            /**
             * 获取最新的id
             */
            this.getLastObjId = function(arr) {
                var o = [];
                if (arr.length > 0) {
                    o = [arr[arr.length - 1]['id']];
                }
                return o;
            }

            this.objectIn = function(arr, obj, key) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i][key] == obj[key]) return i;
                }
                return -1;
            };

            this.keyIn = function(arr, obj, key) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i][key] == obj) return i;
                }
                return -1;
            };

            this.keyInReturnText = function(arr, obj, key) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i][key] == obj) return arr[i]['text'];
                }
                return arr[0]['text'];
            };

            this.findBykey = function(arr, obj, key) {
                for (var i = 0; i < arr.length; i++) {
                    if (arr[i][key] == obj) return arr[i];
                }
                return null;
            };

            this.arrayTextToName = function(arr) {
                if (arr && arr.length > 0) {
                    return $.map(arr, function(indexMap) {
                        indexMap['name'] = indexMap['text']
                        return indexMap;
                    })
                } else {
                    return arr;
                }
            }

            this.find = function(arr, obj, key1, key2) {
                    for (var i = 0; i < arr.length; i++) {
                        if (arr[i][key1] == obj[key2]) return i;
                    }
                    return -1;
                }
                /***
                 **这个数据是否存在
                 **/
            this.has = function(arr, key) {
                if (key == "CollegeYears" || key == "Connections") {
                    if (!arr || (arr.length == 1 && Object.keys(arr[0]).length == 0)) {
                        return false;
                    } else {
                        return true;
                    }
                } else {
                    return (arr && arr.length > 0 && arr[0].length > 0) || (arr && arr.length > 0 && !(arr[0] instanceof Array));
                }
            };


            this.setTags = function($select, values) {
                var values2 = [];
                for (var i = 0, len = values.length; i < len; i++) {
                    var o = values[i];
                    var id = o.id || o.countryCode;
                    var text = o.text || o.name;
                    var type = o.type || o.name;
                    if (!$select.find("option[value=" + id + "]").length) {
                        $select.append('<option value="' + id + '" selected="selected" data-type="' + type + '"' + (undefined != o.isClude ? ' data-isclude="' + o.isClude + '"' : '') + '>' + text + '</option>');
                    }
                }
                $select.find("option[value]").each(function(index, item) {
                    values2.push($(item).attr("value"));
                });
                $select.val(values2).trigger("change");
            }

            this.warning = function(ta) {
                ta.focus();
                ta.removeClass("anim_image_glow").addClass("anim_image_glow");
                $(ta).on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                    $(this).removeClass("anim_image_glow");
                });
            }

            this.warning2 = function(focus, warning) {
                focus.focus();
                warning.removeClass("anim_image_glow").addClass("anim_image_glow");
                warning.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                    $(this).removeClass("anim_image_glow");
                });
            }

            this.warning3 = function(scrollTo, warning) {
                var t = scrollTo.offset().top;
                $(window).scrollTop(t - 50);
                warning.removeClass("anim_image_glow").addClass("anim_image_glow");
                warning.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                    $(this).removeClass("anim_image_glow");
                });
            }

            this.warning4 = function(warning) {
                    warning.removeClass("anim_image_glow").addClass("anim_image_glow");
                    warning.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                        $(this).removeClass("anim_image_glow");
                    });
                }
                /**
                 * 补充 warning3 的方法
                 * @param scrollTo
                 * @param warning
                 */
            this.warning5 = function($scrollTo, num, $warning) {
                $($scrollTo).scrollTop(num);
                $warning.removeClass("anim_image_glow").addClass("anim_image_glow");
                $warning.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                    $(this).removeClass("anim_image_glow");
                });
            }

            /**
             * 失败的红框（不是红框失败，而是它表示失败~）
             * @param msg
             */
            this.alert2 = function(msg) {
                var t = '<div class="alert alert-warning" role="alert" id="http-error"></div>';
                var ta = $("#http-error");
                if (!ta[0]) {
                    $('body').append(t);
                    ta = $("#http-error");
                }
                ta.text(msg);
                ta.removeClass("anim_image_glow2").addClass("anim_image_glow2");
                setTimeout(function() {
                    ta.removeClass("anim_image_glow2");
                }, 3000);
                //firefox下不起作用
                //ta.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend",function(){
                //    $(this).removeClass("anim_image_glow2");
                //});
            }

            //綠色-成功提示框！
            this.alert_success = function(msg) {
                var t = '<div class="alert alert-warning" role="alert" id="http-error"></div>';
                var ta = $("#http-error");
                if (!ta[0]) {
                    $('body').append(t);
                    ta = $("#http-error");
                }
                ta.text("SUCCESS: " + msg);
                ta.removeClass("anim_image_green").addClass("anim_image_green");
                setTimeout(function() {
                    ta.removeClass("anim_image_green");
                }, 3000);
                //firefox下不起作用
                //ta.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend",function(){
                //    $(this).removeClass("anim_image_glow2");
                //});
            }

            //藍色-消息提示框
            this.alert_info = function(msg) {
                var t = '<div class="alert alert-warning" role="alert" id="http-error"></div>';
                var ta = $("#http-error");
                if (!ta[0]) {
                    $('body').append(t);
                    ta = $("#http-error");
                }
                ta.text("Info: " + msg);
                ta.removeClass("anim_image_blue").addClass("anim_image_blue");
                setTimeout(function() {
                    ta.removeClass("anim_image_blue");
                }, 3000);
                //firefox下不起作用
                //ta.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend",function(){
                //    $(this).removeClass("anim_image_glow2");
                //});
            }

            this.alert = function(code, msg) {
                if (msg == undefined) {
                    this.alert2(code);
                } else {
                    var t = '<div class="alert alert-warning" role="alert" id="http-error"></div>';
                    var ta = $("#http-error");
                    if (!ta[0]) {
                        $('body').append(t);
                        ta = $("#http-error");
                    }
                    ta.text("Errcode:" + code + " " + msg);
                    ta.removeClass("anim_image_glow2").addClass("anim_image_glow2");
                    ta.unbind("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend");
                    ta.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                        $(this).removeClass("anim_image_glow2");
                    });
                }
            }

            /**
             *  錯誤提示框，小紅框裡面夾雜著黃色那種效果
             * @param msg
             */
            this.alert3 = function(msg) {
                var t = '<div class="alert alert-warning alert-dismissible fade alert-tip" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><strong>' + I18N.getText('common', 'prompt') + ':</strong><p></p></div>';
                var ta = $("div.alert-tip");
                if (!ta[0]) {
                    $('body').append(t);
                    ta = $("#http-error");
                }

                ta.addClass("in");
                //ta.append(msg);
                ta.find('p').html(msg);
                //ta.unbind("").on("",function(){
                //  $(this).removeClass("in");
                //});
                ta.unbind("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend");
                ta.on("webkitAnimationEnd mozAnimationEnd MSAnimationEnd animationend", function() {
                    $(this).removeClass("in");
                    $(this).find('p').html('')
                });
            }

            this.pricerange = function(node, tag, DATA) {
                tag = tag.toLowerCase();
                var max = DATA.cache.adPublishConditionDetailCache.priceLimit[tag.toUpperCase()];
                var min = "0.01";
                if (tag == "cpm") {
                    min = "0.02";
                } else if (tag == "cpc") {
                    min = "0.01";
                } else if (tag == "cpa") {
                    min = "0.01";
                } else {
                    min = "0.01"
                }
                node.find("div[data-price='" + tag.toUpperCase() + "'] .price-body input[placeholder=amount][id]").attr("placeholder", I18N.getText('createAd', 'moneyRange', [min, max])).attr("max", max).attr("min", min);


            }

            //新版出价范围提示
            this.pricerange2 = function(node, DATA) {
                //node ->.bidSelector
                //todo for test
                //var s="[{\"bidAmountTop\":357,\"billingEvent\":\"APP_INSTALLS\",\"optimizationGoal\":\"APP_INSTALLS\"},{\"bidAmountTop\":459,\"billingEvent\":\"LINK_CLICKS\",\"optimizationGoal\":\"LINK_CLICKS\"},{\"bidAmountTop\":256,\"billingEvent\":\"IMPRESSIONS\",\"optimizationGoal\":\"APP_INSTALLS\"},{\"bidAmountTop\":258,\"billingEvent\":\"IMPRESSIONS\",\"optimizationGoal\":\"LINK_CLICKS\"}]";
                //var pLimits = JSON.parse(s);
                var pLimits = DATA.cache.adPublishConditionDetailCache.priceLimit;
                var gIndex = node.closest(".one-dist").attr("loc-index");
                var locIndex = node.attr("index");
                var max;
                var info = DATA.getBidInfoVo(gIndex, locIndex);
                var min = "0.01";
                if ((info.optimizationGoal == "IMPRESSIONS" && info.billingEvent == "IMPRESSIONS") || (info.optimizationGoal == "REACH" && info.billingEvent == "IMPRESSIONS")) {
                    min = "0.02";
                }
                $(pLimits).each(function(i, limit) {
                    if (limit.billingEvent == info.billingEvent && limit.optimizationGoal == info.optimizationGoal) {
                        max = limit.bidAmountTop;
                    }
                });
                //转成美元。
                max = (Number(max) / 100).toFixed(2);
                node.find("input[name=bidAmountValue]").attr("placeholder", I18N.getText('createAd', 'moneyRange', [min, max])).attr("max", max).attr("min", min);

            }

            /**
             * { 单价的金额范围 }
             *
             * @method     bidAmountRange
             * @param      {<type>}  info        { description }
             * @param      {<type>}  priceLimit  { description }
             */
            this.bidAmountRange = function(info, priceLimit) {
                var range = {
                    min: '0.01'
                }

                if ((info.optimization_goal == "IMPRESSIONS" && info.billing_event == "IMPRESSIONS") || (info.optimization_goal == "REACH" && info.billing_event == "IMPRESSIONS")) {
                    range.min = "0.02";
                }

                if (priceLimit) {
                    if (info.optimization_goal == 'APP_INSTALLS' && info.billing_event == 'IMPRESSIONS') { //应用安装量_展示次数
                        range.max = priceLimit['a_i']
                    } else if (info.optimization_goal == 'APP_INSTALLS' && info.billing_event == 'APP_INSTALLS') { //应用安装量_应用安装
                        range.max = priceLimit['a_a']
                    } else if (info.optimization_goal == 'LINK_CLICKS' && info.billing_event == 'IMPRESSIONS') { ///链接点击量_展示次数
                        range.max = priceLimit['c_i']
                    } else if (info.optimization_goal == 'LINK_CLICKS' && info.billing_event == 'LINK_CLICKS') { //链接点击量_链接点击量
                        range.max = priceLimit['c_c']
                    } else if (info.optimization_goal == 'IMPRESSIONS' && info.billing_event == 'IMPRESSIONS') { //展示次数_展示次数
                        range.max = priceLimit['i_i']
                    } else if (info.optimization_goal == 'REACH' && info.billing_event == 'IMPRESSIONS') { //单日独立覆盖_展示次数
                        range.max = priceLimit['o_i']
                    }
                }

                range.max = range.max ? this.cent_to_dollar(range.max) : '';
                return range;
            }

            /**
             * { 验证
             * 预算 }
             *
             * @method     validateDailyBudget
             * @param      {<type>}  info        { description }
             * @param      {<type>}  bidAmount  { 单价 总预算的时候为0; }
             * @param      {<type>}  budgetVal  { 预算 }
             * @param      {<type>}  budgetType  { 日预算:'daily_budget' 总预算 }
             * @param      {<type>}  startDate  { 总预算的时候排程开始时间 }
             * @param      {<type>}  endDate  {  总预算的时候排程结束时间}
             */
            this.validateBudget = function(info, bidAmount, budgetVal, budgetType, startDate, endDate) {
                // if ('' == budgetVal) {
                //     info.budget = 0;
                //     return false;
                // }
                var topmost = 1000000;
                var billingEvent = info.billing_event;
                //这个版本只用一个出价，这一个就是max
                var max = Number(bidAmount);
                //页面输入的预算
                budgetVal = Number(budgetVal);
                //每日最小预算
                var minDailyBudget = this.getMinDailyBudget(max, billingEvent);
                if (budgetType == 'daily_budget') {
                    //日预算
                    if (budgetVal < minDailyBudget || budgetVal > topmost) {
                        var warning;
                        if (budgetVal > topmost) {
                            warning = I18N.getText('createAd', 'dailyBudgetMaxLimit', '100W');
                        } else if (minDailyBudget == 5 && billingEvent != "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'dailyBudgetMinLimit', '5');
                        } else if (minDailyBudget > 5 && billingEvent != "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'dailyBudgetMinPriceLimit', '*5=' + minDailyBudget);
                        } else if (minDailyBudget == 1 && billingEvent == "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'dailyBudgetMinLimit', '1');
                        } else if (minDailyBudget > 1 && billingEvent == "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'dailyBudgetMinPriceLimit', '*1=' + minDailyBudget);
                        }
                        return warning;
                    } else {
                        return false;
                    }
                } else {
                    //总预算
                    var day = this.calculateScheduleDay(startDate, endDate);
                    var totalBid = Number(minDailyBudget * day).toFixed(2);
                    var top = topmost * day; // 总预算 排程天数 * $1,000,000
                    if (budgetVal < totalBid || budgetVal > top) {
                        var warning;
                        if (budgetVal > top) {
                            warning = I18N.getText('createAd', 'lifetimeBudgetMaxLimit', '100W$') + (day == 1 ? '' : '*' + I18N.getText('createAd', 'scheduleDays'));
                        } else if (minDailyBudget == 5 && billingEvent != "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'lifetimeBudgetMinLimit', [5, totalBid]);
                        } else if (minDailyBudget > 5 && billingEvent != "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'lifetimeBudgetMinPriceLimit', ['5$*', totalBid]);
                        } else if (minDailyBudget == 1 && billingEvent == "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'lifetimeBudgetMinLimit', [1, totalBid]);
                        } else if (minDailyBudget > 1 && billingEvent == "IMPRESSIONS") {
                            warning = I18N.getText('createAd', 'lifetimeBudgetMinPriceLimit', ['', totalBid]);
                        }
                        return warning;
                    } else {
                        return false;
                    }
                }
            }

            this.validateBidAmount = function(_bidAmount, min, max) {
                var result;
                if (_bidAmount != '') {

                    _bidAmount = parseFloat(_bidAmount);
                    //FB接口最高限制
                    if (_bidAmount > 1000) {
                        result = {
                            type: "error",
                            msg: I18N.getText('createAd', 'warn_priceMaxLimit', 1000)
                        }
                    } else if (_bidAmount < min) {
                        //FB接口最低限制
                        result = {
                            type: "error",
                            msg: I18N.getText('createAd', 'warn_priceMinLimit', min)
                        }
                    } else if (_bidAmount > max) {
                        //系统设置最高单价只用于提醒
                        result = {
                            type: "warning",
                            msg: I18N.getText('createAd', 'tip_priceCaps', max)
                        }
                    }
                }
                return result;
            }


            //根据出价和结算方式计算每日的最小预算
            this.getMinDailyBudget = function(maxPrice, billingEvent) {
                var bid;
                if (maxPrice < 1) maxPrice = 1;
                if (billingEvent == "IMPRESSIONS") {
                    //CPM OR OCPM
                    bid = Number(maxPrice).toFixed(2);
                } else {
                    //CPC OR CPA
                    bid = Number(5 * maxPrice).toFixed(2);
                }
                return bid;
            }

            this.calculateScheduleDay = function(_startDate, _endDate) {
                var scheduleDays = (_endDate - _startDate) / 1000 / 60 / 60 / 24;
                var scheduleDaysT = Number(scheduleDays).toFixed(0);
                if (scheduleDays > scheduleDaysT) {
                    scheduleDays = Number(scheduleDaysT) + 1;
                } else {
                    scheduleDays = Number(scheduleDaysT);
                }

                return scheduleDays;
            }

            /**
             * 验证是否是阿拉伯语
             */
            this.isAr = function _isAr(str) {
                //判断文字中是否含有阿拉伯语
                for (var i = 0; i < str.length; i++) {
                    var code = str.charCodeAt(i);
                    if (code > 0x600 && code < 0x6ff) {
                        return true;
                    }
                    if (code > 0xFE70 && code < 0xFEFF) {
                        return true;
                    }
                }
                return false;
            }


            this.addBorderGreen = function(nodeObject) {
                if (window.existsPreviewUserAudience) { //如果存在标记,则说明有生成新的用户定位
                    nodeObject.find('.alert-dismissible').addClass('border-green');
                }
            }

            this.addBorderGreen1 = function(nodeObject) {
                if (window.existsPreviewUserAudience) { //如果存在标记,则说明有生成新的用户定位
                    nodeObject.addClass('border-green');
                }
            }

            this.loading = {
                show: function(dom, cb, _type, _hidIcon) {
                    if (!dom || $(dom).length == 0) {
                        dom = 'html';
                    }
                    var dom = $(dom);
                    var loading = dom.find('> .loading');
                    if (dom[0].nodeName == 'TR') {
                        loading = $('body').find('> .loading');
                    } else if (loading.length > 0) {
                        loading.remove();
                    }
                    var position = dom.css('position');
                    if (position != 'absolute' && position != 'relative' && position != 'fixed') {
                        dom.attr('original', position || '');
                        dom.css('position', 'relative')
                    }
                    //是否属于widget加载
                    var is = '';
                    if (!_hidIcon) {
                        is = '<img src="./imgs/balls.gif"/>';
                        if (_type == 'small') {
                            is = '<img src="./imgs/balls-small.gif"/>';
                        }
                    }

                    var loadingDom = $('<div class="load-area loading"><div class="loadInner kernel">' + is + '</div></div>');
                    if (dom[0].nodeName == 'TR') { //对table类的容器进行特殊处理
                        loadingDom.css(dom.offset());
                        loadingDom.css({ width: dom.width(), height: dom.height() });
                        $('body').append(loadingDom);
                    } else {
                        dom.append(loadingDom);
                    }

                    //进行loading图标居中显示
                    var loadInner = dom.find('> .load-area').find('.loadInner');
                    if (dom[0].nodeName == 'TR') { //对table类的容器进行特殊处理
                        loadInner = loadingDom.find('.loadInner');
                    }
                    var domHeight = dom.height(),
                        windowHeight = $(window).height(),
                        loadInnerHeight = loadInner.height();
                    if (domHeight > windowHeight) {
                        loadInner.css('margin-top', (windowHeight - loadInnerHeight) / 2);
                    } else {
                        loadInner.css('margin-top', (domHeight - loadInnerHeight) / 2);
                    }
                    window.setTimeout(function() {
                        typeof(cb) == 'function' ? cb(): '';
                    }, 100);
                },
                hide: function(dom) {
                    if (!dom) {
                        var dom = 'html';
                    }
                    dom = $(dom);
                    var loading = dom.find('> .load-area');
                    if (dom[0] && dom[0].nodeName == 'TR') {
                        loading = $('body').find('> .load-area');
                    }
                    loading.fadeOut(500, function() {
                        dom.css('position', dom.attr('original') || '')
                        $(this).remove();
                    })
                }
            };

            /**
             * 格式化数字
             * @param number
             * @returns {string}
             */
            this.formatNumber = function(number) {
                var result = '';
                if (number < 10) {
                    result = number;
                } else {
                    var integer = Math.floor(number) + ''; //取到整数部分
                    var digit = '';
                    if (integer.length > 0) {
                        digit = integer.substr(1, 1) == '0' ? '' : '.' + integer.substr(1, 1);
                    }
                    if (integer.length > 6) {
                        result = integer.substr(0, integer.length - 6) + digit + 'M+';
                    } else if (integer.length > 4) {
                        result = integer.substr(0, integer.length - 4) + digit + 'W+';
                    } else if (integer.length > 3) {
                        result = integer.substr(0, integer.length - 3) + digit + 'K+';
                    } else {
                        result = integer;
                    }
                }
                return result;
            };

            /**
             * 格式化数字2
             * @param strNum
             * @returns {string}
             */
            this.formatNum = function(strNum) {
                if (!strNum) {
                    return 0;
                }
                if (strNum.length <= 3) {
                    return strNum;
                }

                if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(strNum)) {
                    return strNum;
                }

                var a = RegExp.$1,
                    b = RegExp.$2,
                    c = RegExp.$3;

                var re = new RegExp();

                re.compile("(\\d)(\\d{3})(,|$)");

                while (re.test(b)) {
                    b = b.replace(re, "$1,$2$3");
                }
                return a + "" + b + "" + c;

            }

            /**
             * 格式化时间
             * @param time
             * @returns {string}
             */
            this.formatTime = function(time) {
                var d = new Date(time)
                return moment(d).format('YYYY-MM-DD HH:mm');
            };

            /**
             * { 带时区格式化 }
             *
             * @method     formatOffsetTime
             * @param      {<type>}  time    { description }
             * @param      {<type>}  offset  { description }
             * @return     {<type>}  { description_of_the_return_value }
             */
            this.formatOffsetTime = function(time, offset) {
                return moment(time).utcOffset(offset).format('YYYY-MM-DD HH:mm');
            }

            /**
             * 格式化%
             * @param n
             * @returns {string}
             */
            this.percentage = function(n) {
                n = n || 0;
                return (n * 100).toFixed(2) + '%';
            }

            /**
             * 格式化货币
             * @param _cent
             * @returns {string}
             */
            this.cent_to_dollar = function(_cent) {
                if (_cent && 0 != _cent) {
                    return (_cent / 100).toFixed(2);
                } else {
                    return Number(0).toFixed(2);
                }
            }

            /*
             * hasmap
             */
            this.hashMap = function() {
                this.elements = new Array();
                //获取MAP元素个数
                this.size = function() {
                        return this.elements.length;
                    }
                    //判断MAP是否为空
                this.isEmpty = function() {
                        return (this.elements.length < 1);
                    }
                    //删除MAP所有元素
                this.clear = function() {
                        this.elements = new Array();
                    }
                    //向MAP中增加元素（key, value)
                this.put = function(_key, _value) {
                    if (this.containsKey(_key)) {
                        this.remove(_key);
                    }
                    this.elements.push({
                        key: _key,
                        value: _value
                    });
                }

                //删除指定KEY的元素，成功返回True，失败返回False
                this.remove = function(_key) {
                    var bln = false;
                    try {
                        for (var i = 0; i < this.elements.length; i++) {
                            if (this.elements[i].key == _key) {
                                this.elements.splice(i, 1);
                                return true;
                            }
                        }
                    } catch (e) {
                        bln = false;
                    }
                    return bln;
                }

                //获取指定KEY的元素值VALUE，失败返回NULL
                this.get = function(_key) {
                    try {
                        for (var i = 0; i < this.elements.length; i++) {
                            if (this.elements[i].key == _key) {
                                return this.elements[i].value;
                            }
                        }
                    } catch (e) {
                        return null;
                    }
                }

                //获取指定索引的元素（使用element.key，element.value获取KEY和VALUE），失败返回NULL
                this.element = function(_index) {
                    if (_index < 0 || _index >= this.elements.length) {
                        return null;
                    }
                    return this.elements[_index];
                }

                //判断MAP中是否含有指定KEY的元素
                this.containsKey = function(_key) {
                    var bln = false;
                    try {
                        for (var i = 0; i < this.elements.length; i++) {
                            if (this.elements[i].key == _key) {
                                bln = true;
                            }
                        }
                    } catch (e) {
                        bln = false;
                    }
                    return bln;
                }

                //判断MAP中是否含有指定VALUE的元素
                this.containsValue = function(_value) {
                    var bln = false;
                    try {
                        for (var i = 0; i < this.elements.length; i++) {
                            if (this.elements[i].value == _value) {
                                bln = true;
                            }
                        }
                    } catch (e) {
                        bln = false;
                    }
                    return bln;
                }

                //获取MAP中所有VALUE的数组（ARRAY）
                this.values = function() {
                    var arr = new Array();
                    for (var i = 0; i < this.elements.length; i++) {
                        arr.push(this.elements[i].value);
                    }
                    return arr;
                }

                //获取MAP中所有KEY的数组（ARRAY）
                this.keys = function() {
                    var arr = new Array();
                    for (var i = 0; i < this.elements.length; i++) {
                        arr.push(this.elements[i].key);
                    }
                    return arr;
                }
            }

            /*
             * 格式转换，金额单位转换
             */
            this.ormat_util = {
                cent_to_dollar: function(_cent) {
                    if (_cent && 0 != _cent) {
                        return (_cent / 100).toFixed(2);
                    } else {
                        return Number(0).toFixed(2);
                    }
                },
                formatNum: function(strNum) {
                    if (!strNum) {
                        return 0;
                    }
                    if (strNum.length <= 3) {
                        return strNum;
                    }

                    if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(strNum)) {
                        return strNum;
                    }

                    var a = RegExp.$1,
                        b = RegExp.$2,
                        c = RegExp.$3;

                    var re = new RegExp();

                    re.compile("(\\d)(\\d{3})(,|$)");

                    while (re.test(b)) {
                        b = b.replace(re, "$1,$2$3");
                    }
                    return a + "" + b + "" + c;

                },
                percentage: function(n) {
                    n = n || 0;
                    return (n * 100).toFixed(2) + '%';
                }
            }

            /*
             * [获取URL里面参数]
             * @param   {String} paramName [URL参数名称]
             * @returns {String} [返回结果,没有则为空]
             */
            this.getUrlParam = function(paramName) {
                var url = location.href;
                var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
                var paraObj = {}
                var j = null;
                for (var i = 0; j = paraString[i]; i++) {
                    paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
                }
                var returnValue = paraObj[paramName.toLowerCase()];
                if (typeof(returnValue) == "undefined") {
                    return "";
                } else {
                    return returnValue;
                }
            }

            //过滤无效的select3数据  a 正确的数据  b存在问题数据
            this.filterSelect3Data = function(a, b) {
                var result = [];
                self.filterTreeData(a, b, result);
                return result;
            };

            //过滤无效的select3数据  a 正确的数据  b存在问题数据
            this.filterTreeData = function(a, b, result) {
                if (a && b && b.length) {
                    if (a && a.length > 0) {
                        $.each(a, function(tmp_1, filterItem) {
                            if (filterItem['son']) {
                                self.filterSelect3Data(filterItem['son'], b, result);
                            } else {
                                $.each(b, function(tmp_2, resultItem) { //遍历原始对象
                                    if (filterItem['id'] == resultItem['id']) {
                                        result.push(resultItem);
                                    }
                                })
                            }
                        })
                    }
                } else {
                    return b;
                }
            };

            /**
             * { 判断长度 }
             *
             * @method     isBlank
             * @param      {<type>}   object  { description }
             * @return     {boolean}  { description_of_the_return_value }
             */
            this.isBlank = function(object) {
                return _.isUndefined(object) || _.isNull(object) || object.length == 0;
            }


            this.bytesToSize = function(bytes) {
                var Sizes = ["Bytes", "KB", "MB", "GB", "TB"];
                if (bytes == 0) {
                    return "0 Byte";
                } else {
                    var i = Math.floor(Math.log(bytes) / Math.log(1024));
                    return Number(bytes / Math.pow(1024, i)).toFixed(2) + " " + Sizes[i];
                }
            }

            this.isEmptyObject = function(obj) {

                if (typeof obj == "object") {
                    for (var name in obj) {
                        return false;
                    }
                }
                return true;
            }

            this.clearObject = function(obj) {
                for (var name in obj) {
                    delete obj[name];
                }
            }

            /**
             * 如果为空，则在$dom节点上提示
             * @param obj
             * @param $dom
             * @returns {boolean}
             */
            this.warningIsBlank = function(obj, $dom, $scrollTo, num) {
                if (this.isBlank(obj)) {
                    this.warning5($scrollTo, num, $dom);
                    return true;
                }
                return false;
            }


            /**
             * { 翻译 }
             */
            this.translate = function(module, key) {
                var keyTmp = key.replaceAll(' ', '_'); //去除空格
                var text = I18N.getText(module, keyTmp);
                if (this.isBlank(text)) { //如果没有翻译,则返回原来的值
                    return key;
                }
                return text;
            }



            /**
             * [isHasEmoji 是否含有 emoji 表情]
             * @param  {[type]}  txt [description]
             * @return {Boolean}     [description]
             */
            this.isHasEmoji = function(txt) {
                return (/\ud83d[\ude00-\ude4f]/g.test(txt));
            }

            /**
             * [replaceEmoji 过滤掉 emoji 表情]
             * @param  {[type]} txt        [description]
             * @param  {[type]} replaceStr [description]
             * @return {[type]}            [description]
             */
            this.replaceEmoji = function(txt, replaceStr) {
                return (txt.replace(/\ud83d[\ude00-\ude4f]/g, replaceStr || ''))
            }

            this.removeEmoji = function($dom) {
                var val = $dom.val();
                if (this.isHasEmoji(val)) {
                    this.alert2(I18N.getText('common', 'disabledInputEmoji'));
                    val = this.replaceEmoji(val);
                    $dom.val(val);
                    return;
                }
            }


            this.warningHasEmoji = function(val, $dom, $scrollTo, num) {
                if (this.isHasEmoji(val)) {
                    this.alert2(I18N.getText('common', 'disabledInputEmoji'));
                    this.warning5($scrollTo, num, $dom);
                    return true;
                }
                return false;
            }


            /**
             * [setCache 设置缓存]
             * @param {[type]} module [模块]
             * @param {[type]} key    [description]
             * @param {[type]} val    [description]
             */
            this.setCache = function(module, key, val) {
                var cache = window.localStorage.getItem(module)
                if (cache == null) {
                    cache = '{}';
                }
                cache = cache == null ? {} : JSON.parse(cache);
                cache[key] = val;
                window.localStorage.setItem(module, JSON.stringify(cache));
            }

            /**
             * [getCache 获取缓存]
             * @param  {[type]} module [模块]
             * @param  {[type]} key    [description]
             * @return {[type]}        [description]
             */
            this.getCache = function(module, key) {
                var cache = window.localStorage.getItem(module)
                if (cache == null) {
                    return null;
                }
                cache = JSON.parse(cache);
                var val = cache[key];
                return val;
            }

        }
        return new Tool();
    });
